 $(function(){
	
	easyloader.base = '../../js/tools/locale/';
    easyloader.load('easyui-lang-zh_CN.js', function(){     
	    var pram={email:'',currentPage:1,startDate:"",endDate:""};
		
         $("#dataGrid").datagrid({
				        height: 450,
						width:1140,
                        pagination: true,
						rownumbers:true,
						striped:true,
						pageList:[15,20,25,30],
						pageSize:15,
						showPageList:true,
						singleSelect:true,
						queryParams:{level:-1,able:-1},
                        url: '../../groupbyajax/user!getUserList.action',
                        columns: [[
						          {field: 'email',title: '用户标识',width: 150,align: 'left'},
						          {field: 'level',title: '用户类型',width: 80,align: 'center'},
						          {field: 'registerTime',title: '注册时间',width: 120,align: 'left'}, 
								  {field: 'tel',title: '电话',width: 120,align: 'left'}, 
								  {field: 'trueName',title: '真实姓名',width: 120,align: 'left'}, 
						          {field: 'able',title: '是否开通',width: 80,align: 'center'}, 
								  {field: 'del',title: '删除',width:120,align: 'center'}
							 ]]
						
			        });		 
			});	
			
	  
});	
/**
 * 显示
 */
function showColumn(field)
{
	$(".datagrid-view2 .datagrid-header div table tr th").each(function(){
		if($(this).attr("field")==field)
		{
			$(this).show();
			return false;
		}
	});
$(".datagrid-column-"+field).show();
}
/**
 * 隐藏
 * @param {Object} field
 */
function hideColumn(field)
{	
$(".datagrid-view2 .datagrid-header div table tr th").each(function(){
		if($(this).attr("field")==field)
		{
			$(this).hide();
			return false;
		}
	});
$(".datagrid-column-"+field).hide();
}
function addButton()
{
	
var pager = $('#dataGrid').datagrid('getPager');   
					pager.pagination({
						pageList:[15,20,25,30],
						pageSize:15,
						showPageList:true,
						buttons:[{
							iconCls:'icon-print',
							handler:function(){
								doPrint();
							}
						}]
					});
}
function ratify(id,able)
{
	var date =new Date();
	$.getJSON("../../groupbyajax/user!ratify.action?times="+date.getTime(),{id:id,able:able},function(data){
		if(data.success)
		{
             if(able==1)
			{
				$("#u"+id).parent().html("<a href='javascript:void(0)' onclick='ratify("+id+",0,this);' id='u"+id+"'><font color='blue'>开通</color></font></a>");
			}else
			{
				$("#u"+id).parent().html("<a href='javascript:void(0)' onclick='ratify("+id+",1,this);' id='u"+id+"'><font color='red'>未开通</color></font>");
			}

		}
	});
}
function delUser(id)
{
	$.messager.confirm('删除', '你确定要删除记录吗?', function(r){
		                          if(r)
								  {
	$.getJSON("../../groupbyajax/user!deleteUser.action",{id:id},function(data){
		if(data.success)
		{
			$("#dataGrid").datagrid('reload');
			$.messager.confirm('删除', '要删除与改用户的所有信息吗?', function(r){
		                          if(r)
								  {
								  	$.getJSON("../../groupbyajax/user!deleteAllUserInfor.action",function(data){
										   
										});
									
								  }
								  });
		}
	})
	}
	});
}
function search()
{
	var name=$("#name").val();
	var startdate=$("#startdate").val();
	var enddate=$("#enddate").val();
	var level=$("#level").val();
	var able=$("#able").val();
	
	$('#dataGrid').datagrid({
				  striped: true,
				  queryParams:{email:name,startTime:startdate,endTime:enddate,level:level,able:able}
			   });
}
